package czh.cocoa.graphics;

import czh.cocoa.foundation.NSObject;

public class CGColor extends NSObject {

	public float alpha;
	
	public float red;
	
	public float green;
	
	public float blue;
	
	private CGImage mPattern;
	
	public CGColor() {
		this(new float[]{1,0,0,0});
	}
	
	public CGColor(float[] components) {
		red = components[0];
		green = components[1];
		blue = components[2];
		alpha = (components.length > 3) ? components[3] : 1;
	}

	public CGColor(CGColor color) {
		red = color.red;
		green = color.green;
		blue = color.blue;
		alpha = color.alpha;
		mPattern = color.pattern();
	}
	
	public CGColor(CGImage pattern) {
		this();
		mPattern = pattern;
	}
	
	public CGImage pattern() {
		return mPattern;
	}

	public int intValue() {
		return (int)(255 * alpha) << 24 | (int)(255 * red) << 16 | 
		       (int)(255 * green) << 8 | (int)(255 * blue);  
	}
	
}
